import 'package:flutter/material.dart';
import 'package:flutterdemo01/demo2/demopage/pageHome.dart';
import 'package:flutterdemo01/demo2/demopage/pageMy.dart';
import 'package:flutterdemo01/demo2/demopage/pageSport.dart';

main() {
  runApp(Demo2App());
}

class Demo2App extends StatefulWidget {
  const Demo2App({Key? key}) : super(key: key);

  @override
  _Demo2AppState createState() => _Demo2AppState();
}

class _Demo2AppState extends State<Demo2App> {
  int _chooseIndex = 0;

  List _pages = [PageHome(), PageSport(), PageMy()];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.lightBlue),
      home: Scaffold(
        appBar: AppBar(
          title: Text('pagedemo1'),
        ),
        body: _pages[_chooseIndex],
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: _chooseIndex,
          items: [
            BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
            BottomNavigationBarItem(icon: Icon(Icons.sports), label: '运动'),
            BottomNavigationBarItem(
                icon: Icon(Icons.mic_external_on), label: '我的'),
          ],
          onTap: (index) {
            setState(() {
              _chooseIndex = index;
            });
          },
        ),
      ),
    );
  }
}

//------跳转传值， 返回